<!DOCTYPE html>
<html>
 <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>小说搜搜-免费且无广告的小说阅读网</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
  </head>
<body>
	<div class="jumbotron">
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<div class="input-group">
						<input type="text" id="keyword" class="form-control"  placeholder="可以输入书名，作者名，甚至可以是符合条件的URL...">
						<span class="input-group-btn">
							<button class="btn btn-default" type="button" id="btnSearch">小说搜搜</button>
						</span>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="container no-table-responsive">
		<table
			class="table table-striped table-bordered table-condensed table-hover">
			<thead>
				<tr style="text-align:center;font-style:800;">
					<th>#</th>
					<td>书名</td>
					<td>作者</td>
					<td>最新章节</td>
					<td>状态</td>
					<td>平台</td>
				</tr>
			</thead>
			<tbody id="list">
			</tbody>
			<!-- <tfoot>
				<tr>
					<td colspan="5">
						<div class="btn-group" style="float: right;">
							<button type="button" class="btn btn-default" id="currentPage">第1/100页</button>
							<button type="button" class="btn btn-default" id="firstPage">首页</button>
							<button type="button" class="btn btn-default" id="previousPage">上一页</button>
							<button type="button" class="btn btn-default" id="nextPage">下一页</button>
							<button type="button" class="btn btn-default" id="lastPage">尾页</button>
							<button type="button" class="btn btn-default" id="gotoPage">跳转</button>
							<input type="text" class="form-control" id="gotopage_text"
								style="width: 80px; display: inline-block" placeholder="页码">
							<input type="hidden" id="hidetxt" value="" />
						</div>
					</td>
				</tr>
			</tfoot> -->
		</table>
	</div>
	<!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/jQuery.js"></script>
    <script src="js/bootstrap.min.js"></script>
	<script src="js/jquery.base64.js"></script>
	<script>
		$(function() {
			$("#btnSearch").click(search);
		})
		function search() {
			var val = $("#keyword").val().trim();
			if (val.length == 0) {
				alert("请输入小说的名字或者作者的名字...");
				return;
			}
			$.ajax({
				url:"./novelSearch.do",
				type:"post",
				dataType:"json",
				data: {
					"keyword" : val,
				},
				error: function (data) {
					alert(data.status);
				},
				success:function(result) {
					$("#list").html("");
					$(result.data).each(function(index,novel){
						var $tr = $("<tr><td>" + (index + 1) + "</td><td><a href='./chapterList.do?url=" + novel.url + "'>"
								+ novel.name + "</a></td><td>"
								+ novel.author + "</td><td>"
								+ novel.lastUpdateChapter + "</td><td>"
								+ (novel.status == 1 ? "连载" : "完结") + "</td><td>"
								+ getPlatform(novel.platformId) + "</td></tr>");
						console.log($tr);
						$("#list").append($tr);
					});
				}
			});
		};
		function getPlatform(platformId) {
			if (platformId == 1) {
				return "顶点小说";
			} else if (platformId == 2) {
				return "笔趣阁";
			} else if (platformId == 3) {
				return "看书中";
			} else if (platformId == 4) {
				return "笔下文学";
			} else {
				return "为知";
			}
		}
	</script>
</body>
</html>